//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    userInfo:{
      avatarUrl:"",//用户头像
      nickName:"",//用户昵称
     }
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that=this;
    /**
     * 获取用户信息
     */
    wx.getUserInfo({
    success:function(res){
      console.log(res);
      var avatarUrl = 'userInfo.avatarUrl';
      var nickName = 'userInfo.nickName';
      that.setData({
      [avatarUrl]: res.userInfo.avatarUrl,
      [nickName]:res.userInfo.nickName,
      })
      console.log(this.data.nickName)
    }
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    }) 
  },
  gotoSchemePage() {
    wx.navigateTo({
      url: '/pages/querySchemeUser/querySchemeUser?userId=' + app.userId
    })
  },
  gotoBackPage() {
    wx.navigateTo({
      url: '/pages/querySchemeUserBack/querySchemeUserBack?userId=' + app.userId
    })
  },
  gotoLogoutPage() {
    app.userId=''
    wx.navigateTo({
      url: '../login/login',
    })
  },
  gotoOut() {
    wx.navigateTo({
      url: '/pages/out/out',
    })
  }
})
